﻿@model ggHD.WebSite.MailService.MailHeader[]

@{
    ViewBag.Title = "Index";
}


@section scripts{
    <script>
        $(function () {
            AddMailInfoRow();

            $("tr.data-row").dblclick(function (ev) {
                CloseInfo();
            });

            $('input[type="checkbox"]').click(function (ev) {
                ev.stopPropagation();
            });

            $('input[type="checkbox"]').dblclick(function (ev) {
                ev.stopPropagation();
            });


            $("input[id='dateFrom']").datepicker({ altFormat: "dd.mm.yy", dateFormat: "dd.mm.yy" }).val('@ViewBag.DateFrom.ToString("dd.MM.yyyy")');
            $("input[id='dateTo']").datepicker({ altFormat: "dd.mm.yy", dateFormat: "dd.mm.yy" }).val('@ViewBag.DateTo.ToString("dd.MM.yyyy")');

            $("#loadNewMailsBtn").click(function (ev) {
                var from = $("input[id='dateFrom']").val();
                var to = $("input[id='dateTo']").val();
                LoadNewMails(from, to);
            });



        });
    </script>
}

@*<div class="toolbox untoggled">
        <button class="btn btn-xs btn-success">В задачи</button>
        <button class="btn btn-xs btn-danger">Удалить</button>
        <div class="alert alert-danger">
            <span>Блокировать</span>
            <button class="btn btn-xs btn-danger">Домен</button>
            <button class="btn btn-xs btn-danger">Адрес</button>
        </div>
    </div>*@

<nav class="navbar navbar-default sub-navbar" role="navigation">
    <div class="collapse navbar-collapse pull-left">
        <ul class="nav navbar-nav">
            <li><a href="#" style="color:green">В задачи</a></li>
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" style="color:red" data-toggle="dropdown">
                    Удалить<b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a>Сообщение</a></li>
                    <li class="divider"></li>
                    <li><a>Заблокировать адрес</a></li>
                    <li><a>Заблокировать домен</a></li>
                    <li class="divider"></li>
                    <li><a>Все письма с этим адресом</a></li>
                    <li><a>Все письма с этим доменом</a></li>
                </ul>
              </li>
            </ul>
    </div>
    <div class="collapse navbar-collapse pull-right">
        <form class="navbar-form navbar-left" action="/RawMails/Index" method="post">
            <div class="form-group">
                <input type="text" class="form-control date-picker" id="dateFrom" name="dateFrom" /><span> - </span>
                <input type="text" class="form-control date-picker" id="dateTo" name="dateTo" />
            </div>
            <button type="submit" class="btn btn-default">Фильтр</button>
        </form>
        <ul class="nav navbar-nav">
            <li>
                <button type="button" class="btn btn-default navbar-btn" id="loadNewMailsBtn">Загрузить</button>
            </li>
        </ul>

    </div>

</nav>
<table class="table table-hover table-condensed">
    <thead>
        <tr>
            <th><input type="checkbox" id="allCheckbox" /></th>
            <th style="width:100px;">From</th>
            <th>DateSent</th>
            <th>DateLoaded</th>
            <th>Subject</th>
            <th>MailAccount</th>
        </tr>
    </thead>
    <tbody style="font-size:80%">
        @foreach (var mailHeader in Model)
        {
            <tr mail-id="@mailHeader.Id" class="data-row">
                <td><input type="checkbox" /></td>
                <td>@mailHeader.FromAddress (@mailHeader.FromName)</td>
                <td>@mailHeader.DateSent</td>
                <td>@mailHeader.DateLoaded</td>
                <td>@mailHeader.MsgSubject</td>
                <td>@mailHeader.MailAccount</td>
            </tr>
        }
    </tbody>
</table>

@Scripts.Render("~/bundles/views/raw-mails")